<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.global.js'></script>
</head>

<body>
    <div id='app'>
        <div id="app">
            <my-component v-model.capitalize="myText"></my-component>
            {{ myText }}
        </div>
    </div>

    <script>
        const app = Vue.createApp({
            data(){
                return {
                    myText:"ximen"
                }
            }
        })

        app.component('my-component', {
            props: {
                modelValue: String,
                modelModifiers: {
                    default: () => ({})
                }
            },
            emits: ['update:modelValue'],
            methods: {
                emitValue(e) {
                    let value = e.target.value
                    if (this.modelModifiers.capitalize) {
                        value = value.charAt(0).toUpperCase() + value.slice(1)
                    }
                    this.$emit('update:modelValue', value)
                }
            },
            template: `<input
                type="text"
                :value="modelValue"
                @input="emitValue">`
            })

        app.mount('#app')
    </script>
</body>

</html>